Update not working...
am 22.01.2008 17:55:31 von JJ297
After a user adds their name, address etc to a form and hit the submit
button an email is generated to go to someone to update the database.
This is what's being sent and works fine:
Dim ocdoEmail As New Object
ocdoEmail = Server.CreateObject("CDO.Message")
ocdoEmail.To = Session("GetEmail")
ocdoEmail.From = Session("GetEmail")
ocdoEmail.Subject = "Training Resource Material Request"
ocdoEmail.HTMLBody = "
FillRequest.aspx?RequestorID=" & x & """>Click link to fill out the
training library resource request"
ocdoEmail.send()
After clicking on the hyperlink you are taken to FillRequest.aspx with
some of the info displayed in a details view and then two text boxes
are displayed so the user can update ship date, and due date.
My problem is the two text boxes are not being updated in the
database. Can someone assist me don't know what I'm missing.
Here's my stored procedure to update the info:
CREATE procedure updateloanerinfo
@requestorid int,
@shipdate datetime,
@duedate datetime
AS update LibraryRequest
set
[shipdate] = @shipdate,
[duedate] = @duedate
where requestorid = @requestorid
GO
Here's fillrequest.aspx.vb code behind:
Protected Sub LoanRequest_Click(ByVal sender As Object, ByVal e As
System.EventArgs) Handles LoanRequest.Click
Dim conn As New
Data.SqlClient.SqlConnection(ConfigurationManager.Connection Strings("TrainUserConnectionString").ConnectionString)
'add string
Dim cmd As New Data.SqlClient.SqlCommand
With cmd
.Connection = conn 'the connection
.CommandType = Data.CommandType.StoredProcedure
.CommandText = "UpdateloanerInfo"
.Parameters.AddWithValue("@shipdate", ShipDateTxt.Text)
.Parameters.AddWithValue("@duedate", DueDateTxt.Text)
End With
Try
conn.Open()
cmd.ExecuteNonQuery()
Catch ex As Data.SqlClient.SqlException
Finally
conn.Dispose()
End Try
End Sub
Re: Update not working...
am 22.01.2008 18:01:13 von Patrice
Hi,
IMHO you should never use an empty Catch clause. Remove this cloause so that
you( and us) can see the error message raised by the application rather than
guessing (hint : your sp have 3 parameters but you only define 2 parameters
in your code). Wihtout the catch clause you should have a message hinting at
this (or whaterver else error you could have)...
--
Patrice
"JJ297" a écrit dans le message de news:
051d7bf9-a86d-4545-baf4-384ea2a3f601@c23g2000hsa.googlegroup s.com...
> After a user adds their name, address etc to a form and hit the submit
> button an email is generated to go to someone to update the database.
> This is what's being sent and works fine:
>
> Dim ocdoEmail As New Object
> ocdoEmail = Server.CreateObject("CDO.Message")
> ocdoEmail.To = Session("GetEmail")
> ocdoEmail.From = Session("GetEmail")
> ocdoEmail.Subject = "Training Resource Material Request"
> ocdoEmail.HTMLBody = "
> FillRequest.aspx?RequestorID=" & x & """>Click link to fill out the
> training library resource request"
> ocdoEmail.send()
>
> After clicking on the hyperlink you are taken to FillRequest.aspx with
> some of the info displayed in a details view and then two text boxes
> are displayed so the user can update ship date, and due date.
>
> My problem is the two text boxes are not being updated in the
> database. Can someone assist me don't know what I'm missing.
>
> Here's my stored procedure to update the info:
>
> CREATE procedure updateloanerinfo
>
> @requestorid int,
> @shipdate datetime,
> @duedate datetime
>
>
> AS update LibraryRequest
>
> set
> [shipdate] = @shipdate,
> [duedate] = @duedate
>
> where requestorid = @requestorid
> GO
>
> Here's fillrequest.aspx.vb code behind:
>
> Protected Sub LoanRequest_Click(ByVal sender As Object, ByVal e As
> System.EventArgs) Handles LoanRequest.Click
> Dim conn As New
> Data.SqlClient.SqlConnection(ConfigurationManager.Connection Strings("TrainUserConnectionString").ConnectionString)
>
> 'add string
> Dim cmd As New Data.SqlClient.SqlCommand
> With cmd
> .Connection = conn 'the connection
> .CommandType = Data.CommandType.StoredProcedure
> .CommandText = "UpdateloanerInfo"
> .Parameters.AddWithValue("@shipdate", ShipDateTxt.Text)
> .Parameters.AddWithValue("@duedate", DueDateTxt.Text)
>
>
> End With
>
> Try
> conn.Open()
> cmd.ExecuteNonQuery()
>
> Catch ex As Data.SqlClient.SqlException
>
>
> Finally
> conn.Dispose()
> End Try
>
>
> End Sub
Re: Update not working...
am 22.01.2008 19:37:44 von JJ297
On Jan 22, 12:01=A0pm, "Patrice" wrote:
> Hi,
>
> IMHO you should never use an empty Catch clause. Remove this cloause so th=
at
> you( and us) can see the error message raised by the application rather th=
an
> guessing (hint : your sp have 3 parameters but you only define 2 parameter=
s
> in your code). Wihtout the catch clause you should have a message hinting =
at
> this (or whaterver else error you could have)...
>
> --
> Patrice
>
> "JJ297" a =E9crit dans le message de news:
> 051d7bf9-a86d-4545-baf4-384ea2a3f...@c23g2000hsa.googlegroup s.com...
>
>
>
> > After a user adds their name, address etc to a form and hit the submit
> > button an email is generated to go to someone to update the database.
> > This is what's being sent and works fine:
>
> > Dim ocdoEmail As New Object
> > ocdoEmail =3D Server.CreateObject("CDO.Message")
> > ocdoEmail.To =3D Session("GetEmail")
> > ocdoEmail.From =3D Session("GetEmail")
> > ocdoEmail.Subject =3D "Training Resource Material Request"
> > ocdoEmail.HTMLBody =3D "
> > FillRequest.aspx?RequestorID=3D" & x & """>Click link to fill out the
> > training library resource request"
> > =A0 =A0 =A0 =A0ocdoEmail.send()
>
> > After clicking on the hyperlink you are taken to FillRequest.aspx with
> > some of the info displayed in a details view and then two text boxes
> > are displayed so the user can update ship date, and due date.
>
> > My problem is the two text boxes are not being updated in the
> > database. =A0Can someone assist me don't know what I'm missing.
>
> > Here's my stored procedure to update the info:
>
> > CREATE procedure updateloanerinfo
>
> > @requestorid int,
> > @shipdate datetime,
> > @duedate datetime
>
> > AS update LibraryRequest
>
> > set
> > [shipdate] =3D @shipdate,
> > [duedate] =3D @duedate
>
> > where requestorid =3D @requestorid
> > GO
>
> > Here's fillrequest.aspx.vb code behind:
>
> > Protected Sub LoanRequest_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles LoanRequest.Click
> > =A0 =A0 =A0 =A0Dim conn As New
> > Data.SqlClient.SqlConnection(ConfigurationManager.Connection Strings("Tra=
inU=ADserConnectionString").ConnectionString)
>
> > =A0 =A0 =A0 =A0'add string
> > =A0 =A0 =A0 =A0Dim cmd As New Data.SqlClient.SqlCommand
> > =A0 =A0 =A0 =A0With cmd
> > =A0 =A0 =A0 =A0 =A0 =A0.Connection =3D conn 'the connection
> > =A0 =A0 =A0 =A0 =A0 =A0.CommandType =3D Data.CommandType.StoredProcedure=
> > =A0 =A0 =A0 =A0 =A0 =A0.CommandText =3D "UpdateloanerInfo"
> > =A0 =A0 =A0 =A0 =A0 =A0.Parameters.AddWithValue("@shipdate", ShipDateTxt=
..Text)
> > =A0 =A0 =A0 =A0 =A0 =A0.Parameters.AddWithValue("@duedate", DueDateTxt.T=
ext)
>
> > =A0 =A0 =A0 =A0End With
>
> > =A0 =A0 =A0 =A0Try
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 conn.Open()
> > =A0 =A0 =A0 =A0 =A0 =A0cmd.ExecuteNonQuery()
>
> > =A0 =A0 =A0 =A0Catch ex As Data.SqlClient.SqlException
>
> > =A0 =A0 =A0 =A0Finally
> > =A0 =A0 =A0 =A0 =A0 =A0conn.Dispose()
> > =A0 =A0 =A0 =A0End Try
>
> > =A0 End Sub- Hide quoted text -
>
> - Show quoted text -
Thanks Patrice,
I added the 3rd parameter and it's now working.
Re: Update not working...
am 22.01.2008 19:38:12 von JJ297
On Jan 22, 12:01=A0pm, "Patrice" wrote:
> Hi,
>
> IMHO you should never use an empty Catch clause. Remove this cloause so th=
at
> you( and us) can see the error message raised by the application rather th=
an
> guessing (hint : your sp have 3 parameters but you only define 2 parameter=
s
> in your code). Wihtout the catch clause you should have a message hinting =
at
> this (or whaterver else error you could have)...
>
> --
> Patrice
>
> "JJ297" a =E9crit dans le message de news:
> 051d7bf9-a86d-4545-baf4-384ea2a3f...@c23g2000hsa.googlegroup s.com...
>
>
>
> > After a user adds their name, address etc to a form and hit the submit
> > button an email is generated to go to someone to update the database.
> > This is what's being sent and works fine:
>
> > Dim ocdoEmail As New Object
> > ocdoEmail =3D Server.CreateObject("CDO.Message")
> > ocdoEmail.To =3D Session("GetEmail")
> > ocdoEmail.From =3D Session("GetEmail")
> > ocdoEmail.Subject =3D "Training Resource Material Request"
> > ocdoEmail.HTMLBody =3D "
> > FillRequest.aspx?RequestorID=3D" & x & """>Click link to fill out the
> > training library resource request"
> > =A0 =A0 =A0 =A0ocdoEmail.send()
>
> > After clicking on the hyperlink you are taken to FillRequest.aspx with
> > some of the info displayed in a details view and then two text boxes
> > are displayed so the user can update ship date, and due date.
>
> > My problem is the two text boxes are not being updated in the
> > database. =A0Can someone assist me don't know what I'm missing.
>
> > Here's my stored procedure to update the info:
>
> > CREATE procedure updateloanerinfo
>
> > @requestorid int,
> > @shipdate datetime,
> > @duedate datetime
>
> > AS update LibraryRequest
>
> > set
> > [shipdate] =3D @shipdate,
> > [duedate] =3D @duedate
>
> > where requestorid =3D @requestorid
> > GO
>
> > Here's fillrequest.aspx.vb code behind:
>
> > Protected Sub LoanRequest_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs) Handles LoanRequest.Click
> > =A0 =A0 =A0 =A0Dim conn As New
> > Data.SqlClient.SqlConnection(ConfigurationManager.Connection Strings("Tra=
inU=ADserConnectionString").ConnectionString)
>
> > =A0 =A0 =A0 =A0'add string
> > =A0 =A0 =A0 =A0Dim cmd As New Data.SqlClient.SqlCommand
> > =A0 =A0 =A0 =A0With cmd
> > =A0 =A0 =A0 =A0 =A0 =A0.Connection =3D conn 'the connection
> > =A0 =A0 =A0 =A0 =A0 =A0.CommandType =3D Data.CommandType.StoredProcedure=
> > =A0 =A0 =A0 =A0 =A0 =A0.CommandText =3D "UpdateloanerInfo"
> > =A0 =A0 =A0 =A0 =A0 =A0.Parameters.AddWithValue("@shipdate", ShipDateTxt=
..Text)
> > =A0 =A0 =A0 =A0 =A0 =A0.Parameters.AddWithValue("@duedate", DueDateTxt.T=
ext)
>
> > =A0 =A0 =A0 =A0End With
>
> > =A0 =A0 =A0 =A0Try
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 conn.Open()
> > =A0 =A0 =A0 =A0 =A0 =A0cmd.ExecuteNonQuery()
>
> > =A0 =A0 =A0 =A0Catch ex As Data.SqlClient.SqlException
>
> > =A0 =A0 =A0 =A0Finally
> > =A0 =A0 =A0 =A0 =A0 =A0conn.Dispose()
> > =A0 =A0 =A0 =A0End Try
>
> > =A0 End Sub- Hide quoted text -
>
> - Show quoted text -
Thanks for telling me also to never use an empty try catch clause too.